package com.eeds.controller.pc;

import com.eeds.base.BaseController;
import com.eeds.common.model.BaseWrapper;
import com.eeds.common.model.PageInfo;
import com.eeds.interceptor.NeedAuth;
import com.eeds.model.culture.req.ReqAddCultureVO;
import com.eeds.model.culture.req.ReqGetCultureInfoVO;
import com.eeds.model.culture.req.ReqUpdateCultureVO;
import com.eeds.model.culture.res.ResGetCultureListVO;
import com.eeds.model.culture.vo.CultureVO;
import com.eeds.service.culture.CultureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Api(value = "文化接口", description = "文化接口")
@RequestMapping("pc/culture/")
public class CultureController extends BaseController {

    @Autowired
    private CultureService cultureService;

    /**
     * description:添加文化
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/addCulture", method = RequestMethod.POST)
    @ApiOperation("添加文化")
    public BaseWrapper<Integer> addCulture(@Valid @ModelAttribute ReqAddCultureVO reqAddCultureVO){
        Integer result = cultureService.addCulture(reqAddCultureVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:修改文化
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth(role = 1)
    @RequestMapping(value = "/updateCulture", method = RequestMethod.POST)
    @ApiOperation("修改文化")
    public BaseWrapper<Integer> updateCulture(@Valid @ModelAttribute ReqUpdateCultureVO reqUpdateCultureVO){
        Integer result = cultureService.updateCulture(reqUpdateCultureVO);
        return new BaseWrapper<>(result);
    }

    /**
     * description:获取文化列表
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth
    @RequestMapping(value = "/getCultureList", method = RequestMethod.GET)
    @ApiOperation("获取文化列表")
    public BaseWrapper<PageInfo<ResGetCultureListVO>> getCultureList(){
        PageInfo<ResGetCultureListVO> result = cultureService.getCultureList();
        return new BaseWrapper<>(result);
    }

    /**
     * description:获取文化信息
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth
    @RequestMapping(value = "/getCulture", method = RequestMethod.GET)
    @ApiOperation("获取文化信息")
    public BaseWrapper<CultureVO> getCultureInfo(@Valid @ModelAttribute ReqGetCultureInfoVO reqGetCultureInfoVO){
        CultureVO result = cultureService.getCultureInfo(reqGetCultureInfoVO);
        return new BaseWrapper<>(result);
    }

}
